
const routes = [

    //访问路由“/”,自动重定向到"/home"
    {
        path: '',
        redirect: '/topmenus'
    },
    {
        path: '/login',
        name: 'Login',
        component: () => import('@/views/login.vue')

    },
    {
        path: '/topmenus',
        name: 'topmenus',
        component: () => import('@/views/home/topmenus.vue'),
        children:[
            {
                path:'/account',
                name:'account',
                component:() => import('@/views/home/account/account.vue')
            },
            {
                path:'/business',
                name:'business',
                component:() => import('@/views/home/business/business.vue')
            },
            {
                path:'/check',
                name:'check',
                component:() => import('@/views/home/check/check.vue')
            },
            {
                path:'/arrange',
                name:'arrange',
                component:() => import('@/views/home/arrange/arrange.vue')
            },
            {
                path:'/consult',
                name:'consult',
                component:() => import('@/views/home/consult/consult.vue')
            },
            {
                path:'/dashboard',
                name:'dashboard',
                component:() => import('@/views/home/dashboard/dashboard.vue')
            },
            {
                path:'/label',
                name:'label',
                component:() => import('@/views/home/label/label.vue')
            },
            {
                path:'/home',
                name:'home',
                component:() => import('@/views/home/home/home.vue')

            },
            {
                path:'/user',
                name:'user',
                component:() => import('@/views/home/user/user.vue')

            }
        ]
    },
    {
        path: '/query',
        name: 'Query',
        component: () => import('@/views/boss/boss.vue')
    },
    {
        path: '/404',
        name: "NotFound",
        component: () => import('@/views/404.vue')
    }

];

export const existsRoute = (path) => {
    for (let i = 0; i < routes.length; i++) {
        const r = routes[i];
        if (r.path == path) {
            return true;
        }
        if (r.children && r.children.length) {
            for (let k = 0; k < r.children.length; k++) {
                const sr = r.children[k];
                if (sr.path == path) {
                    return true;
                }
            }
        }
    }
    return false;
};

export default routes;